from docx import Document
from docx.shared import Inches


def resize_images_in_word(doc_path, output_path, target_width):
    doc = Document(doc_path)
    for shape in doc.inline_shapes:
        if hasattr(shape, "width"):
            shape.width = Inches(target_width)
    doc.save(output_path)


if __name__ == "__main__":
    input_doc = 'D:\opt\zpj.docx'
    output_doc = 'D:\opt\zpj_out.docx'
    width_cm = 13
    resize_images_in_word(input_doc, output_doc, width_cm)
